Skip to content

Fix bookmark favicon selection in oEmbed fallback#28939

Merged
9larsons merged 3 commits into
TryGhost:mainfrom
lujuldotcom:fix/bookmark-favicon-fallback-type
Jul 1, 2026
Merged

Fix bookmark favicon selection in oEmbed fallback#28939
9larsons merged 3 commits into
TryGhost:mainfrom
lujuldotcom:fix/bookmark-favicon-fallback-type

Conversation

@lujuldotcom

Copy link
Copy Markdown
Contributor

Hi @9larsons,

I tested the merged change and found that bookmark cards can still prefer Apple Touch Icons in the oEmbed fallback path.

The bookmark-specific favicon logic works when fetchBookmarkData is called with type === 'bookmark', but the fallback path currently calls it with the original undefined type:

if (!data && !type) {
    data = await this.fetchBookmarkData(url, body, type);
}

That means pickFn does not enter the bookmark-specific branch and falls back to the previous Apple-first behavior.

This change passes 'bookmark' explicitly in that fallback path:

data = await this.fetchBookmarkData(url, body, 'bookmark');

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6385d0db-5fd8-479c-8b98-94500e095742

📥 Commits

Reviewing files that changed from the base of the PR and between d30a80e and 6bf6124.

📒 Files selected for processing (1)
  • ghost/core/core/server/services/oembed/oembed-service.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • ghost/core/core/server/services/oembed/oembed-service.js

Walkthrough

fetchOembedDataFromUrl now passes 'bookmark' explicitly to fetchBookmarkData when no oEmbed data is found and no type is provided. The bookmark-card favicon/icon comment in fetchBookmarkData was also updated.

Possibly related PRs

  • TryGhost/Ghost#28768: Also touches the bookmark-card favicon/icon selection logic in oembed-service.js.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: bookmark favicon selection in the oEmbed fallback path.
Description check ✅ Passed The description is directly related to the change and accurately explains the fallback bookmark favicon fix.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
ghost/core/core/server/services/oembed/oembed-service.js (1)

568-568: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a regression test for the undefined-type fallback.

This fixes the right contract, but the supplied tests only cover the two halves separately (fetchOembedDataFromUrl() returning bookmark data, and fetchBookmarkData(..., 'bookmark') preferring the standard favicon). A single test for the exact !type fallback path would lock this bug down.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ghost/core/core/server/services/oembed/oembed-service.js` at line 568, Add a
regression test for the exact undefined-type fallback path in oembed-service.js:
the current coverage splits the behavior across fetchOembedDataFromUrl() and
fetchBookmarkData(), but it does not verify the branch where !type triggers
fetchBookmarkData(url, body, 'bookmark'). Add a focused test around
OEmbedService’s fallback logic to assert that an undefined oEmbed type resolves
to bookmark data and still uses the standard favicon behavior, so this specific
contract is locked down.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@ghost/core/core/server/services/oembed/oembed-service.js`:
- Line 568: Add a regression test for the exact undefined-type fallback path in
oembed-service.js: the current coverage splits the behavior across
fetchOembedDataFromUrl() and fetchBookmarkData(), but it does not verify the
branch where !type triggers fetchBookmarkData(url, body, 'bookmark'). Add a
focused test around OEmbedService’s fallback logic to assert that an undefined
oEmbed type resolves to bookmark data and still uses the standard favicon
behavior, so this specific contract is locked down.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 34c66b35-e43d-46e9-a29d-96dc5c1d1a14

📥 Commits

Reviewing files that changed from the base of the PR and between 0ed0d9f and d30a80e.

📒 Files selected for processing (1)
  • ghost/core/core/server/services/oembed/oembed-service.js

lujuldotcom and others added 2 commits June 30, 2026 16:26
The fallback path (!data && !type) now passes 'bookmark' so pickFn
selects the standard favicon instead of the Apple Touch icon. The
existing favicon tests only covered explicit type === 'bookmark', so
the fallback path with an undefined type was uncovered. Also corrected
the pickFn comment, which wrongly described the oembed fallback as a
scaled-up tile preferring Apple Touch.
@9larsons 9larsons force-pushed the fix/bookmark-favicon-fallback-type branch from d30a80e to 6bf6124 Compare June 30, 2026 21:30
@9larsons

9larsons commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

@lujuldotcom Thanks for this - added a test to capture this which would've prevented this fix with the previous PR!

@nx-cloud

nx-cloud Bot commented Jul 1, 2026

Copy link
Copy Markdown

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit a6e724e

Command Status Duration Result
nx run ghost:test:ci:integration ✅ Succeeded 2m 13s View ↗
nx run ghost:test:integration ✅ Succeeded 2m 43s View ↗
nx run ghost:test:legacy ✅ Succeeded 2m 56s View ↗
nx run ghost:test:e2e ✅ Succeeded 2m 21s View ↗
nx run-many --target=build --projects=tag:publi... ✅ Succeeded <1s View ↗
nx run-many -t test:unit -p ghost ✅ Succeeded 29s View ↗
nx run-many -t lint -p ghost ✅ Succeeded 35s View ↗
nx run @tryghost/admin:build ✅ Succeeded 6s View ↗
Additional runs (2) ✅ Succeeded ... View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-07-01 14:10:28 UTC

@9larsons 9larsons enabled auto-merge (squash) July 1, 2026 14:18
@9larsons 9larsons merged commit ffa040a into TryGhost:main Jul 1, 2026
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants